import request from '@/sheep/request';

const DeviceApi = {
  // 获得示例图片列表
  getModelList:  (serialNumber) => {
    return request({
      url: '/sp/device/models',
      method: 'GET',
      params: {
        serialNumber: serialNumber,
      },
      custom: {
        showLoading: false,
        showError: false,
      },
    });
  },
  // 获得示例图片列表
  getDeviceInfo:  (serialNumber) => {
    return request({
      url: '/sp/device/get',
      method: 'GET',
      params: {
        serialNumber: serialNumber,
      },
      custom: {
        showLoading: false,
        showError: false,
      },
    });
  },

  //绑定用户信息
  bindMember:  (uuid) => {
    return request({
      url: '/sp/device/bind',
      method: 'POST',
      params: {
        uuid: uuid,
      },
      custom: {
        showLoading: false,
        showError: false,
      },
    });
  },

  getDeviceSerial:  () => {
    //获取设备码
    const equipmentId =DeviceApi.getUrlParams('deviceSerial');
    uni.removeStorageSync('equipmentId');
    if (equipmentId) {
      uni.setStorageSync('equipmentId', equipmentId);
    }
    return equipmentId;
  },

  getUrlParams:  (name) => {
    const params = new URLSearchParams(window.location.search);
    return params.get(name);;
  },

};
export default DeviceApi;